from itsdangerous import TimedJSONWebSignatureSerializer as Serializer, BadData
from mail.settings import SECRET_KEY


def generic_verify_url(user_id):
    serializer = Serializer(secret_key=SECRET_KEY, expires_in=3600)
    token = serializer.dumps({'id': user_id})
    return 'http://www.meiduo.site:8080/success_verify_email.html?token=' + token.decode()

def check_verify_email_token(token):
    serializer = Serializer(secret_key=SECRET_KEY, expires_in=3600)
    data = serializer.loads(token)
    return data['id']